import './index.scss'
import { App } from 'antd'
import { useState } from 'react'
import { useMount } from 'ahooks'
import "@grapecity/wijmo.cultures/wijmo.culture.zh"

import { WijmoClassBase, WijmoClassMultiRow, WijmoClassOLAP } from './WijmoClass'
const ClassMapping = { Base: WijmoClassBase, Multi: WijmoClassMultiRow, OLAP: WijmoClassOLAP }

const Wijmo = ({ page }) => {
    const { modal } = App.useApp()
    const [Template, setTemplate] = useState()
    useMount(async () => {

        await import(`./Wijmo/${page}.jsx`)
            .then(async res => {
                const templateData = await res.default()
                const Template = ClassMapping[templateData.classification]
                setTemplate(<Template templateData={templateData} />)
            })
            .catch((err) => {
                console.log(err)
                modal.info({ title: '当前页面未定义!', content: `当前页面路径--${page}` })
            })
    })
    return (
        <div className='Wijmo'>
            {Template && Template}
        </div>
    )
}

export default Wijmo;